# check_data.py
import os
import pandas as pd
from config import Config


def check_data_files():
    """检查数据文件"""
    print("=== 数据文件检查 ===")

    total_files = 0
    total_rows = 0

    for activity in Config.ACTIVITY_MAPPING.keys():
        activity_dir = os.path.join(Config.RAW_DATA_DIR, activity)

        if os.path.exists(activity_dir):
            csv_files = [f for f in os.listdir(activity_dir) if f.endswith('.csv')]

            if csv_files:
                print(f"\n{activity} 目录:")
                activity_rows = 0

                for csv_file in csv_files:
                    file_path = os.path.join(activity_dir, csv_file)
                    try:
                        df = pd.read_csv(file_path)
                        print(f"  {csv_file}: {len(df)} 行, 列: {df.columns.tolist()}")
                        activity_rows += len(df)
                        total_files += 1
                    except Exception as e:
                        print(f"  {csv_file}: 读取失败 - {e}")

                print(f"  {activity} 总数据行数: {activity_rows}")
                total_rows += activity_rows
            else:
                print(f"\n{activity} 目录: 没有CSV文件")
        else:
            print(f"\n{activity} 目录: 不存在")

    print(f"\n=== 统计汇总 ===")
    print(f"总文件数: {total_files}")
    print(f"总数据行数: {total_rows}")

    if total_files == 0:
        print("\n建议:")
        print("1. 确保CSV文件放在正确的目录中")
        print("2. 文件命名示例: 静止1.csv, 走1.csv, 跑1.csv, 蹲1.csv, 摔倒1.csv")
        print("3. 每个文件应该包含传感器数据列: x_value, y_value, z_value")


if __name__ == "__main__":
    check_data_files()